﻿using System;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CommandLine.ConsoleUtils;
using CommandLine.OptParse;
using System.ComponentModel;

namespace TestListGenerator
{
    /// <summary>
    /// A class that is used to store the configuration for generating
    /// Test Lists. This class is either populated via code (for example:
    /// A translation from msbuild format into this class) or with the
    /// CSharpOptParse class, which populates this class with values
    /// from the command line. For more details on CSharpOptParse, 
    /// read the CHM file in the CSharpOptParse project
    /// </summary>
    public class Configuration
    {
        /// <summary>
        /// The path to the DLL to generate the TestList for
        /// </summary>
        [ShortOptionName('d')]
        [LongOptionName("dll")]
        [UseNameAsLongOption(false)]
        [OptDef(OptValType.ValueReq)]
        [Category("Setup")]
        [Description("The path to the Tests DLL to generate the TestLists for")]
        public string DllPath
        {
            get;
            set;
        }

        /// <summary>
        /// The path to the config file that will be used to run the tests with
        /// </summary>
        [ShortOptionName('c')]
        [LongOptionName("config")]
        [UseNameAsLongOption(false)]
        [OptDef(OptValType.ValueOpt)]
        [Description("The path to the config file that will be used to run the tests with")]
        [DefaultValue(DEFAULT_RUN_CONFIG_PATH)]
        [Category("Setup")]
        public string RunConfigPath
        {
            get
            {
                if (_runConfigPath == null)
                {
                    return DEFAULT_RUN_CONFIG_PATH;
                }
                else
                {
                    return _runConfigPath;
                }
            }
            set
            {
                _runConfigPath = value;
            }
        }
        private string _runConfigPath;
        public const string DEFAULT_RUN_CONFIG_PATH = "localtestrun.testrunconfig";
 
        /// <summary>
        /// The path to where you want the output file to be generated
        /// </summary>
        [ShortOptionName('o')]
        [LongOptionName("output")]
        [UseNameAsLongOption(false)]
        [OptDef(OptValType.ValueOpt)]
        [Description("The path to where you want the output TestList to be generated")]
        [DefaultValue(DEFAULT_OUTPUT_PATH)]
        [Category("Setup")]
        public string OutputPath
        {
            get
            {
                if (_outputPath == null)
                {
                    return DEFAULT_OUTPUT_PATH;
                }
                else
                {
                    return _outputPath;
                }
            }
            set
            {
                _outputPath = value;
            }
        }
        private string _outputPath;
        public const string DEFAULT_OUTPUT_PATH = "generatedTestList.vsmdi";

        /// <summary>
        /// A list of categories that should be included in the
        /// generated test list
        /// </summary>
        [ShortOptionName('i')]
        [LongOptionName("include")]
        [UseNameAsLongOption(false)]
        [OptDef(OptValType.MultValue, ValueType = typeof(string))]
        [Description("A list of categories that should be included in the test list generated. NB: You can define multiple categories by repeating the parameter - see examples.")]
        [Category("Criteria")]
        public StringCollection IncludedCategories
        {
            get
            {
                return this._includedCategories;
            }
            set
            {
                this._includedCategories = value;
            }
        }
        // CSharpOptParse required this attribute to be instantiated, which
        // is why I didn't use the default get;set;
        private StringCollection _includedCategories = new StringCollection();

        /// <summary>
        /// A list of categories that should be excluded in the
        /// generated test list
        /// </summary>
        [ShortOptionName('e')]
        [LongOptionName("exclude")]
        [UseNameAsLongOption(false)]
        [OptDef(OptValType.MultValue, ValueType = typeof(string))]
        [Description("A list of categories that should be excluded from the test list generated. NB: You can define multiple categories by repeating the parameter - see examples.")]
        [Category("Criteria")]
        public StringCollection ExcludedCategories
        {
            get
            {
                return this._excludedCategories;
            }
            set
            {
                this._excludedCategories = value;
            }
        }
        // CSharpOptParse required this attribute to be instantiated, which
        // is why I didn't use the default get;set;
        private StringCollection _excludedCategories = new StringCollection();

    }
}
